package cn.juque.jdfsystem.controller;

import cn.hutool.core.bean.BeanUtil;
import cn.juque.common.base.BaseResponseVO;
import cn.juque.common.constants.MessageEnum;
import cn.juque.jdfsystem.bo.StatisticsCountBO;
import cn.juque.jdfsystem.bo.StatisticsFileBO;
import cn.juque.jdfsystem.service.IStatisticsService;
import cn.juque.jdfsystem.vo.statistics.StatisticsCountVO;
import cn.juque.jdfsystem.vo.statistics.StatisticsFileVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author juque
 * @version 1.0.0
 * <ul>
 *     <li>StatisticsController</li>
 * </ul>
 * @date 2023-05-06 11:47:52
 **/
@Slf4j
@Controller
@RequestMapping("/jdf/statistics")
public class StatisticsController {

    @Resource
    private IStatisticsService statisticsService;

    /**
     * 查询
     *
     * @return BaseResponseVO
     */
    @GetMapping(value = "/count")
    @ResponseBody
    public BaseResponseVO<StatisticsCountVO> count() {
        StatisticsCountBO bo = this.statisticsService.count();
        StatisticsCountVO vo = new StatisticsCountVO();
        BeanUtil.copyProperties(bo, vo);
        return new BaseResponseVO<>(MessageEnum.OK, vo);
    }

    /**
     * 查询
     *
     * @return BaseResponseVO
     */
    @GetMapping(value = "/fileCount")
    @ResponseBody
    public BaseResponseVO<StatisticsFileVO> fileCount(Integer days) {
        StatisticsFileBO bo = this.statisticsService.fileCount(days);
        StatisticsFileVO vo = new StatisticsFileVO();
        BeanUtil.copyProperties(bo, vo);
        return new BaseResponseVO<>(MessageEnum.OK, vo);
    }
}
